package com.vue.admin.service.common.mybatis.entity;

import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.code.ORDER;

import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.util.Date;

/**
 * @program: vue-admin-service
 * @description: 通用基本实体类
 * @author: zhangyangyang
 * @create: 2020-04-03 10:43
 *
 * @MappedSuperclass 注解用来标识父类
 * 1、此类不是一个完整的实体类，他将不会映射到数据库表，但是他的属性都将映射到其子类的数据库字段中。
 * 2、此类不能再标注@Entity或@Table注解，也无需实现序列化接口。
 **/

@MappedSuperclass
public abstract class BaseEntity<T>{

    /**
     * @Id 将属性定义为主键
     * @KeySql 是否使用 JDBC 方式获取主键，取主键的sql，order在MySQL自增长主键中用after
     */
    @Id
    @KeySql(useGeneratedKeys = true, sql = "SELECT LAST_INSERT_ID()", order = ORDER.AFTER)
    private T id;
    private Integer createUser;
    private Integer updateUser;
    private Date createTime;
    private Date updateTime;
    private Integer deleted;
    private String language;

    public T getId() {
        return id;
    }

    public void setId(T id) {
        this.id = id;
    }

    public Integer getCreateUser() {
        return createUser;
    }

    public void setCreateUser(Integer createUser) {
        this.createUser = createUser;
    }

    public Integer getUpdateUser() {
        return updateUser;
    }

    public void setUpdateUser(Integer updateUser) {
        this.updateUser = updateUser;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getDeleted() {
        return deleted;
    }

    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }
}
